package com.test.template.publish.config;

import com.test.template.publish.config.fac.VelocityTemplateConfig;
import com.test.template.tool.Tool;
import lombok.Data;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

@Data
public class ApiConfig implements VelocityTemplateConfig {
    private String tableName; // 数据库表名称
    private String prefix;// 控制器的prefix

    // 5个请求方法
    private String save = "/op/save";

    private String get = "/op";

    private String update = "/op/update";

    private String delete = "/op";

    private String page = "/op/page";

    HashMap<String, String> apiNames = new HashMap<>();

    private String fileName;

    public void innerGenerate() {
        List<String> apiPrefix = new ArrayList<>(Arrays.asList("list", "get", "add", "update", "delete"));
        for (String apiName : apiPrefix) {
            String addApiName = apiName + Tool.toUpperCase(tableName, 1);
            apiNames.put(apiName, addApiName);
        }
        fileName = tableName + ".js";
    }
}
